package com.auth.client.controller;

import com.auth.client.config.auth.Auth;
import com.auth.client.config.context.UserContext;
import com.auth.client.config.domain.User;
import com.auth.client.util.TokenUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 *
 * @author: mhSui 2020/07/01
 */
@RestController
public class TestController {

    @GetMapping("test")
    //@Auth(mustAuthentication = false)
    public String test(){
        return "test";
    }

    @GetMapping("login")
    @Auth(mustAuthentication = false)
    public String login(){
        String token = TokenUtil.createToken("1","18738838238889");
        return token;
    }


    @GetMapping("getUserInfo")
    public String getMessage(){
        User user = UserContext.get();
        return user.getId()+"__"+user.getMobile();
    }
}
